<template>
  <div class="grayPage">
   <div class="banner" :style="{'height':bannerHeight+'px'}">
    <div class="header">
      <div class="head">
        <img :src="this.head">
      </div>
      <div class="name text-center">{{name}}</div>
    </div>
  </div>
  <div class="centerContent box-shadow content">
    <div class="info" @click='goToPersonalData()'>
      <span v-if="!isCompleted">完善资料</span>
      <span v-else>我的资料</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
    <div class="info" @click='goToReturnFee()'>
      <span>我的返费</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
    <div class="info" @click='goToSignedJobs()'>
      <span>我的报名</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
    <!--<div class="info" @click='goToreferral()'>-->
      <!--<span>我的推荐费</span>-->
      <!--<img class="arrow" src="/static/wechat/images/arrow@2x.png">-->
    <!--</div>-->
    <div class="info" @click='goToExtend()'>
      <span>邀新奖励</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
    <div class="info" @click='goToWages()'>
      <span>我的工资</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
    <div class="info" @click='goToMyCooperation()'>
      <span>我的加盟</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
    <div class="info" @click='goToMyAgent()'>
      <span>我的经纪人</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
    <div class="info" @click='goToMyLogistics()'>
      <span>后勤</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
    <div class="info" @click='goToTogether()'>
      <span>业务合作</span>
      <img class="arrow" src="/static/wechat/images/arrow@2x.png">
    </div>
  </div>
  <bottomMenu :menuType="menuType"></bottomMenu>
</div>
</template>

<script>
  import {zgzUser} from'@/controller'
  import bottomMenu from './bottomMenu.vue'
  export default {
    name: 'center',
    data () {
      return {
        bannerHeight: window.innerWidth / (20 / 9),
        msg: 'center',
        head:this.head,
        name:this.name,
        isCompleted:false,
        menuType:3 // 4代表个人中心
      }
    },
    components: {
      'bottomMenu': bottomMenu
    },
    mounted(){
      this.initCenter();
    },
    methods:{
      goToSignedJobs(){
        this.$router.push({
          path:`/signedJobs`
        })
      },
      goToPersonalData(){
        this.$router.push({
          path:`/personalData`
        })
      },
      goToReturnFee(){
        this.$router.push({
          path:`/returnFee`
        })
      },
      goToreferral(){
        this.$router.push({
          path:`/referralFee`
        })
      },
      goToExtend(){
        this.$router.push({
          path:`/extendDetail`
        })
      },
      goToWages(){
        this.$router.push({
          path:`/wages`
        })
      },
      goToMyAgent(){
        this.$router.push({
          path:`/myAgent`
        })
      },
      goToMyLogistics() {
        this.$router.push({
          path:`/myLogistics`
        })
      },
      goToMyCooperation() {
        this.$router.push({
          path:`/myCooperation`
        })
      },
      goToTogether() {
        this.$router.push({
          path:`/together`
        })
      },
      initCenter(){
        let hasBinding = localStorage.getItem('hasBind1');
        if(hasBinding=='true'){
          zgzUser().then((data)=>{
            console.log(data);
            if(data.code === 0){
              if(data.data.phone!=null)
                localStorage.setItem('hasBind1',true)
              this.name=data.data.userNickName;
              this.head=data.data.userHeadimgurl;
              if(data.data.userBirthday){
                this.isCompleted = true
              }
            }else{
              this.$toast.center('get zgz user error')
            }
          })

        }else {
          this.$router.push({
            path: `/binding/0/-1/`,
          })
        }
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.banner{
  background: url("/static/wechat/images/centerBg@2x.png");
  background-size: 100%;
}
</style>
